package com.xizi.controller;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RestController
@RequestMapping("/chat")
public class ChatClientController {

    private final ChatClient chatClient;

    public ChatClientController(ChatClient chatClient) {
        this.chatClient = chatClient;
    }

    @RequestMapping(value = "/s",produces = "text/html;charset=utf-8")
    public Flux<String> s(String message){
        return chatClient
                .prompt()
                .user(message)
                .stream()
                .content();
    }

}
